// 通用类型定义
export interface ApiResponse<T = unknown> {
  code: number
  message: string
  data: T
}

export interface PageResult<T> {
  records: T[]
  total: number
  page: number
  size: number
  pages?: number
}

export interface User {
  id: number
  openId?: string
  nickname: string
  avatarUrl?: string
  gender: number
  genderText?: string
  country?: string
  province?: string
  city?: string
  language?: string
  phone?: string
  email?: string
  status: number
  statusText?: string
  userType: number
  userTypeText?: string
  points: number
  studyProgress: number
  lastLoginTime?: string
  lastLoginIp?: string
  remark?: string
  createTime: string
  updateTime: string
}

export interface Culture {
  id: number
  title: string
  subtitle?: string
  coverImage?: string
  summary?: string
  content?: string
  category: number
  categoryText?: string
  tags?: string
  viewCount: number
  likeCount: number
  favoriteCount: number
  shareCount: number
  sortOrder: number
  status: number
  statusText?: string
  isRecommend: boolean
  isTop: boolean
  creatorId?: number
  creatorName?: string
  createTime: string
  updateTime: string
}


export interface Tutorial {
  id: number
  title: string
  subtitle?: string
  coverImage?: string
  summary?: string
  content?: string
  videoUrl?: string
  videoDuration?: number
  difficultyLevel: number
  difficultyLevelText?: string
  category: number
  categoryText?: string
  tags?: string
  toolsRequired?: string
  materialsRequired?: string
  stepsCount: number
  estimatedTime?: number
  viewCount: number
  likeCount: number
  favoriteCount: number
  studyCount: number
  sortOrder: number
  status: number
  statusText?: string
  isRecommend: boolean
  isFree: boolean
  creatorId?: number
  creatorName?: string
  createTime: string
  updateTime: string
}

export interface TutorialQuery {
  page: number
  size: number
  keyword?: string
  category?: number
  difficultyLevel?: number
  isFree?: boolean
  orderBy?: string
  isRecommend?: boolean
}

export interface TutorialStep {
  id: number
  tutorialId: number
  stepNumber: number
  title: string
  description?: string
  imageUrl?: string
  videoUrl?: string
  videoDuration?: number
  tips?: string
  sortOrder: number
  createTime: string
  updateTime: string
}

export interface News {
  id: number
  title: string
  subtitle?: string
  coverImage?: string
  summary?: string
  content?: string
  type: number
  tags?: string
  author?: string
  source?: string
  publishTime?: string
  eventStartTime?: string
  eventEndTime?: string
  eventLocation?: string
  viewCount: number
  likeCount: number
  shareCount: number
  sortOrder: number
  status: number
  isRecommend: boolean
  isTop: boolean
  creatorId?: number
  creatorName?: string
  createTime: string
  updateTime: string
}

export interface Banner {
  id: number
  title: string
  description?: string
  imageUrl: string
  linkType: number
  linkUrl?: string
  targetType?: string
  targetId?: number
  sortOrder: number
  status: number
  startTime?: string
  endTime?: string
  creatorId?: number
  creatorName?: string
  createTime: string
  updateTime: string
}

export interface UserStudy {
  id: number
  userId: number
  tutorialId: number
  progress: number
  currentStep: number
  totalSteps: number
  studyDuration: number
  isCompleted: boolean
  completedTime?: string
  lastStudyTime?: string
  createTime: string
  updateTime: string
  tutorial?: {
    id: number
    title: string
    subtitle?: string
    coverImage?: string
    summary?: string
    difficultyLevel: number
    category: number
    estimatedTime?: number
    stepsCount: number
    viewCount: number
    likeCount: number
    favoriteCount: number
  }
}

export interface UserFavorite {
  id: number
  userId: number
  targetType: string
  targetId: number
  createTime: string
  content?: {
    title?: string
    subtitle?: string
    coverImage?: string
    summary?: string
    [key: string]: any
  }
}

export interface UserLike {
  id: number
  userId: number
  targetType: string
  targetId: number
  createTime: string
}

// 查询参数接口
export interface BaseQuery {
  page: number
  size: number
  keyword?: string
}

export interface CultureQuery extends BaseQuery {
  category?: number
  orderBy?: string
  isRecommend?: boolean
  isTop?: boolean
}

export interface TutorialQuery extends BaseQuery {
  category?: number
  difficultyLevel?: number
  isFree?: boolean
  isRecommend?: boolean
}

export interface NewsQuery extends BaseQuery {
  type?: number
  isRecommend?: boolean
  isTop?: boolean
}

// 请求参数接口
export interface LoginRequest {
  username: string
  password: string
}

export interface RegisterRequest {
  nickname: string
  phone?: string
  email?: string
  password?: string
  avatarUrl?: string
  gender?: number
  country?: string
  province?: string
  city?: string
  language?: string
  userType?: number
  remark?: string
}

export interface UpdateProfileRequest {
  nickname?: string
  avatarUrl?: string
  email?: string
  phone?: string
  country?: string
  province?: string
  city?: string
}

export interface ChangePasswordRequest {
  oldPassword: string
  newPassword: string
  confirmPassword: string
}

// 常量定义
export const CULTURE_CATEGORIES = {
  1: '历史文化',
  2: '技法介绍', 
  3: '作品欣赏',
  4: '文化内涵'
} as const

export const TUTORIAL_CATEGORIES = {
  1: '传统剪纸',
  2: '现代剪纸',
  3: '节庆剪纸',
  4: '动物剪纸',
  5: '花卉剪纸',
  6: '人物剪纸',
  7: '建筑剪纸',
  8: '装饰剪纸'
} as const

export const TUTORIAL_DIFFICULTY = {
  1: '初级',
  2: '中级',
  3: '高级'
} as const

export const NEWS_TYPES = {
  1: '活动',
  2: '资讯',
  3: '公告'
} as const

export const USER_GENDER = {
  0: '未知',
  1: '男',
  2: '女'
} as const
